#include <iostream>
#include <string>
#include <regex>

int main()
{
    std::string str = "GET /bitejiuyeke/login?user=xiaomin&pass=123123 HTTP/1.1\r\n";
    std::smatch matches;
    //请求方法的匹配 GET HEAD POST PUT DELETE ...
    //[^?] 代表匹配非 ？字符
    //\\?(.*) \\?表示原始的?字符，(.*)表示提取?之后的任意0-n个字符
    std::regex e("(GET|HEAD|POST|PUT|DELETE) ([^?]*)(?:\\?(.*))? (HTTP/1\\.[01])(?:\n|\r\n)?");

    bool ret = std::regex_match(str, matches, e);
    if(ret == false)
    {
        return -1;
    }
    for(auto& s : matches)
    {
        std::cout << s << std::endl;
    }
    return 0;
}